include(${PROJECT_PATH}/target/tools/cmake/compile_flags.cmake)

list(APPEND componets schedimp pltdef gsp sched diag dcs tsync vtc config log slib hal schedio cageregister rtc_client rtc gsp_eth gsp_serial bistframe usc_slave ringbuf rdb io)

add_custom_target(prepare_file
  ALL
  COMMAND
        ${CMAKE_COMMAND} -E copy ${PROJECT_PATH}/target/comp/dcs/t_dcs/t_dcs.c ${PROJECT_PATH}/target/app/usc/src/t_dcs.c
  COMMAND
        ${CMAKE_COMMAND} -E copy ${PROJECT_PATH}/target/comp/dcs/t_dcs/t_dcsdefault.h ${PROJECT_PATH}/target/comp/dcs/t_dcs/t_dcsdefault.h
  COMMAND
        ${CMAKE_COMMAND} -E copy ${PROJECT_PATH}/target/app/usc/src/t_io.c ${PROJECT_PATH}/target/app/usc/src/t_io.c
  WORKING_DIRECTORY
        ${CMAKE_CURRENT_SOURCE_DIR}
  COMMENT
        "copy file for build uscp_vc1"
  )

add_executable(uscp_vc1
${PROJECT_PATH}/target/app/usc/src/main.c
${PROJECT_PATH}/target/app/usc/src/t_dcs.c
${PROJECT_PATH}/target/app/usc/src/t_io.c
${PROJECT_PATH}/target/app/usc/src/uscmain.c
${PROJECT_PATH}/target/app/usc/src/VcSchedPhase.c
)

target_include_directories(uscp_vc1 PRIVATE
${PROJECT_PATH}/target/app/vc/inc
${PROJECT_PATH}/target/comp/io
)

add_dependencies(uscp_vc1 prepare_file)

target_compile_definitions(uscp_vc1 PRIVATE
    -DVC1
)

target_link_options(uscp_vc1 PRIVATE -T${PROJECT_PATH}/target/app/usc/usc_x86_64.ld)

target_link_libraries(uscp_vc1 PRIVATE
    -Wl,--start-group
    ${componets}
    -Wl,--end-group
)
